package com.example.cinema.bindingdata;

import android.view.View;
import android.widget.ImageView;

import androidx.databinding.BindingAdapter;
import androidx.databinding.ObservableField;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.example.cinema.R;
import com.example.cinema.drawview.VideoPlayer;

public class PlayerData {

    @BindingAdapter("setplayurl")
    public static void seturls(View view,String url)
    {
        if(url!=null)
        {
            VideoPlayer player = (VideoPlayer) view;
            player.SetUrlPlayer(url);
        }
    }

    @BindingAdapter("playuserimg")
    public static void PlayUserImg(View view,String url)
    {
        if(url!=null)
        {
            RequestOptions options = new RequestOptions()
                    .placeholder(R.mipmap.defaut_img)
                    .error(R.mipmap.defaut_img)
                    .fallback(R.mipmap.defaut_img);
            Glide.with(view).load(url)
                    .apply(options)
                    .into((ImageView) view);
        }
    }
    public ObservableField<String> titles = new ObservableField<>();//影片标题
    public ObservableField<String> videovid = new ObservableField<>();//影片ID
    public ObservableField<String> videobrief = new ObservableField<>();//影片简介
    public ObservableField<String> videotype = new ObservableField<>();//影片类型
    public ObservableField<String> totaltime = new ObservableField<>();//开始时间
    public ObservableField<String> currenttime = new ObservableField<>();//当前时间
    public ObservableField<Integer> totalprogress = new ObservableField<>();//总进度
    public ObservableField<Integer> nowprogress = new ObservableField<>();//当前进度
    public ObservableField<String>  playerurl = new ObservableField<>();//播放地址
    public ObservableField<String> userimg = new ObservableField<>();//用户头像
    public ObservableField<String> videouser = new ObservableField<>();//用户名称
    public ObservableField<String> videouptime = new ObservableField<>();//上传时间
    public ObservableField<String> videolove = new ObservableField<>();//收到点赞
    public ObservableField<String> videoshort = new ObservableField<>();//播放短片地址

}
